#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<unordered_map>
#include<string>

using namespace std;

void dfs(vector<int>& p, int u, int& res, int limit,int n)
{
    if (u == 3)
    {
        int tot = p[0] + p[1] + p[2];
        if (tot != n) return;
        res++;
        cout << p[0] << " " << p[1] << " " << p[2] << endl;
        return;
    }

    for (int i = 0; i <= limit; i++)
    {
        p[u] = i;
        dfs(p, u + 1, res, limit,n);
    }
}
int distributeCandies(int n, int limit) {
    vector<int> p(3);
    int res = 0;
    dfs(p, 0, res, limit,n);
    return res;
}

int main()
{
    distributeCandies(5, 2);
	return 0;
}